package shop.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import shop.dao.IAddressDao;
import shop.model.Address;
import shop.service.IAddressService;

@RestController
@RequestMapping("address")
public class AddressController {

	@Resource
	private IAddressDao dao;
	
	@Resource
	private IAddressService service;
	
	@RequestMapping("findAddressById.do")
	public Address findAddressById(int id) {
		return dao.findById(id);
	}
	
	@RequestMapping("findAddressByUId.do")
	public Map findAddressByUId(int uid) {
		List<Address> list = dao.findByUId(uid);
		Map map = new HashMap();
		map.put("code", "0");
		map.put("msg", "");
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}
	
	@RequestMapping("del.do")
	public int del(int id) {
		return service.del(id);
	}
	
}
